layui.use(function() {
	var layer = layui.layer,
		$ = layui.jquery,
		util = layui.util;;
	document.getElementById('fullscreen-button').addEventListener('click', toggleFullScreen);
	//全屏参数
	function toggleFullScreen() {
		if (!document.fullscreenElement) {
			// 进入全屏
			document.documentElement.requestFullscreen();
		} else {
			// 退出全屏
			if (document.exitFullscreen) {
				document.exitFullscreen();
			}
		}
	}
	
	//右侧弹出框的内容
	const slideHtml = `
		<div class="yz-menu-nav" style="display: none">
			<div class="yz-menu-nav-item">
				<div class="yz-menu-nav-item-img"></div>
				<div class="yz-menu-nav-item-child layui-hide">
					<div class="triangle"></div>
					<div class="yz-menu-nav-item-child-title">标题</div>
					<div class="yz-menu-nav-item-child-item">服务区子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
				</div>
			</div>
			<div class="yz-menu-nav-item">
				<div class="yz-menu-nav-item-img" ></div>
				<div class="yz-menu-nav-item-child layui-hide">
					<div class="triangle"></div>
					<div class="yz-menu-nav-item-child-item">菜单7</div>
					<div class="yz-menu-nav-item-child-item">菜单8</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
				</div>
			</div>
			<div class="yz-menu-nav-item">
				<div class="yz-menu-nav-item-img"></div>
				<div class="yz-menu-nav-item-child layui-hide">
					<div class="triangle"></div>
					<div class="yz-menu-nav-item-child-title">标题</div>
					<div class="yz-menu-nav-item-child-item">服务区子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
				</div>
			</div>
			<div class="yz-menu-nav-item">
				<div class="yz-menu-nav-item-img"></div>
				<div class="yz-menu-nav-item-child layui-hide">
					<div class="triangle"></div>
					<div class="yz-menu-nav-item-child-title">标题</div>
					<div class="yz-menu-nav-item-child-item">服务区子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
				</div>
			</div>
			<div class="yz-menu-nav-item">
				<div class="yz-menu-nav-item-img"></div>
				<div class="yz-menu-nav-item-child layui-hide">
					<div class="triangle"></div>
					<div class="yz-menu-nav-item-child-title">标题</div>
					<div class="yz-menu-nav-item-child-item">服务区子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
				</div>
			</div>
			<div class="yz-menu-nav-item">
				<div class="yz-menu-nav-item-img"></div>
				<div class="yz-menu-nav-item-child layui-hide">
					<div class="triangle"></div>
					<div class="yz-menu-nav-item-child-title">标题</div>
					<div class="yz-menu-nav-item-child-item">服务区子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
				</div>
			</div>
			<div class="yz-menu-nav-item">
				<div class="yz-menu-nav-item-img"></div>
				<div class="yz-menu-nav-item-child layui-hide">
					<div class="triangle"></div>
					<div class="yz-menu-nav-item-child-title">标题</div>
					<div class="yz-menu-nav-item-child-item">服务区子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
				</div>
			</div>
			<div class="yz-menu-nav-item">
				<div class="yz-menu-nav-item-img"></div>
				<div class="yz-menu-nav-item-child layui-hide">
					<div class="triangle"></div>
					<div class="yz-menu-nav-item-child-title">标题</div>
					<div class="yz-menu-nav-item-child-item">服务区子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
				</div>
			</div>
			<div class="yz-menu-nav-item">
				<div class="yz-menu-nav-item-img"></div>
				<div class="yz-menu-nav-item-child layui-hide">
					<div class="triangle"></div>
					<div class="yz-menu-nav-item-child-title">标题</div>
					<div class="yz-menu-nav-item-child-item">服务区子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
				</div>
			</div>
			<div class="yz-menu-nav-item">
				<div class="yz-menu-nav-item-img"></div>
				<div class="yz-menu-nav-item-child layui-hide">
					<div class="triangle"></div>
					<div class="yz-menu-nav-item-child-title">标题</div>
					<div class="yz-menu-nav-item-child-item">服务区子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
				</div>
			</div>
			<div class="yz-menu-nav-item">
				<div class="yz-menu-nav-item-img"></div>
				<div class="yz-menu-nav-item-child layui-hide">
					<div class="triangle"></div>
					<div class="yz-menu-nav-item-child-title">标题</div>
					<div class="yz-menu-nav-item-child-item">服务区子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
				</div>
			</div>
			<div class="yz-menu-nav-item">
				<div class="yz-menu-nav-item-img"></div>
				<div class="yz-menu-nav-item-child layui-hide">
					<div class="triangle"></div>
					<div class="yz-menu-nav-item-child-title">标题</div>
					<div class="yz-menu-nav-item-child-item">服务区子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
				</div>
			</div>
			<div class="yz-menu-nav-item">
				<div class="yz-menu-nav-item-img"></div>
				<div class="yz-menu-nav-item-child layui-hide">
					<div class="triangle"></div>
					<div class="yz-menu-nav-item-child-title">标题</div>
					<div class="yz-menu-nav-item-child-item">服务区子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
				</div>
			</div>
			<div class="yz-menu-nav-item">
				<div class="yz-menu-nav-item-img"></div>
				<div class="yz-menu-nav-item-child layui-hide">
					<div class="triangle"></div>
					<div class="yz-menu-nav-item-child-title">标题</div>
					<div class="yz-menu-nav-item-child-item">服务区子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
					
				</div>
			</div>
			<div class="yz-menu-nav-item">
				<div class="yz-menu-nav-item-img"></div>
				<div class="yz-menu-nav-item-child layui-hide">
					<div class="triangle"></div>
					<div class="yz-menu-nav-item-child-title">标题</div>
					<div class="yz-menu-nav-item-child-item">服务区子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
				</div>
			</div>
			<div class="yz-menu-nav-item">
				<div class="yz-menu-nav-item-img"></div>
				<div class="yz-menu-nav-item-child layui-hide">
					<div class="triangle"></div>
					<div class="yz-menu-nav-item-child-title">标题</div>
					<div class="yz-menu-nav-item-child-item">服务区子系统注册</div>
					<div class="yz-menu-nav-item-child-item">子系统注册</div>
				</div>
			</div>
		</div>
	`
	$('body').append(slideHtml);
	
	
	//右侧弹出框
	$('#slideRight').click(function(){
		var selectClazz = $('.yz-menu-nav')
		var clazz = selectClazz.attr('style');
		if(clazz && clazz.indexOf('display: none') > -1){
			selectClazz.show({direction:'left'},'slow')
		}else{
			selectClazz.hide({direction:'left'},'slow');
		}
	});
	
	//点击一级出现二级
	$('.yz-menu-nav-item-img').click(function(){
		$('.yz-menu-nav-item-child').addClass('layui-hide');
		var child = $(this).parent().find('.yz-menu-nav-item-child');
		if(!child) return;
		if(child.attr('class') && child.attr('class').indexOf('layui-hide') > -1){
			child.removeClass('layui-hide')
		}
	});
	//点击二级
	$(document).on('click','.yz-menu-nav-item-child-item',function(){
		layer.msg("二级菜单：" + $(this).text());
		$('.yz-menu-nav-item-child').addClass('layui-hide');
	});
	// 点击区域外
	$(document).on('click', function(event) {
	    var clickTarget = $(event.target);
	    if (!clickTarget.closest('.yz-menu-nav-item').length) {
	        $('.yz-menu-nav-item-child').addClass('layui-hide');
	    }
	});

	
	//设置显示框
	$('#openHide').click(function(){
		var clazz = $('.yz-downa').attr('class');
		if(clazz.indexOf('layui-hide') > -1){
			$('.yz-downa').removeClass('layui-hide')
		}else{
			$('.yz-downa').addClass('layui-hide')
		}
	})
	
	//系统登录弹出框
	$('#sysLoginLayer').click(function(){
		layer.open({
			type: 2,
			closeBtn: 0,
			area: ['1400px', '900px'],
			title: false,
			shade: 0.6, // 遮罩透明度
			shadeClose: true, // 点击遮罩区域，关闭弹层
			maxmin: false, // 允许全屏最小化
			anim: 0, 
			content: 'sso.html'
	    })
	});
	
	$('.yz-common-title-content span.t').click(function(e){
		const index = $(".yz-common-title-content span.t").index($(this));
		console.log(index)
		$(this).addClass('cur').siblings().removeClass('cur');
		$('.news-list').hide();
		$('.news-list').eq(index).show();
	});
	
	$('#layerClose').click(function(){
		parent.layer.closeAll();
	});

});